package com.demo.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
 
@Entity
@Table(name="t_user")
public class User implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "uid")
    private Long id;
    @Column(name = "username")
    private String username;
    @Column(name = "password")
    private String password;
    @Column(name = "sex")
    private String sex;
    @Column(name = "height")
    private Integer height;
    
    @Column(name = "birth")
    @Temporal(TemporalType.TIMESTAMP)//列如果是date类型，这里就必须要指定DATE；列如果是时间戳类型，这里就必须要指定TIMESTAMP类型
    @JsonFormat(pattern = "yyyy年MM月dd", timezone = "GMT+8")  //前端拿到的时间格式化  
    private Date birth;
    
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy年MM月dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")   //入参时，请求报文只需要传入yyyymmddhhmmss字符串进来，则自动转换为Date类型数据  
    @Column(name = "created")
    private Date created;
    
    @Transient
    private Date startBirth,endBirth;
   
    
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public Date getBirth() {
		return birth;
	}
	public void setBirth(Date birth) {
		this.birth = birth;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public Integer getHeight() {
		return height;
	}
	public void setHeight(Integer height) {
		this.height = height;
	}
	public Date getCreated() {
		return created;
	}
	public void setCreated(Date created) {
		this.created = created;
	}
	public Date getStartBirth() {
		return startBirth;
	}
	public void setStartBirth(Date startBirth) {
		this.startBirth = startBirth;
	}
	public Date getEndBirth() {
		return endBirth;
	}
	public void setEndBirth(Date endBirth) {
		this.endBirth = endBirth;
	}
	@Override
	public String toString() {
		return "User [id=" + id + ", username=" + username + ", password=" + password + ", sex=" + sex + ", height="
				+ height + ", birth=" + birth + ", created=" + created + "]";
	}
	
}